package com.lixinxinlove.jaychoumusic.page

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.lixinxinlove.jaychoumusic.R
import com.lixinxinlove.jaychoumusic.page.util.Screen
import kotlinx.coroutines.delay

/**
 *   author ： lixinxin
 *   time    ： 2021-12-24
 *   email：895330766@qq.com
 */
@Composable
fun WelcomeScreen(navController: NavController) {

    val context = LocalContext.current


    Box(modifier = Modifier.fillMaxSize()) {
        Image(
            painter = painterResource(id = R.mipmap.ic_logo),
            contentDescription = "logo",
            modifier = Modifier
                .align(Alignment.Center)
                .height(100.dp)
                .width(100.dp)
                .clip(RoundedCornerShape(50.dp))
        )
    }

    LaunchedEffect(context) {
        delay(2000)
        navController.navigate(Screen.LoginScreen.route)
    }

}


@Preview
@Composable
fun WelcomeScreenPreview() {
    val navController = rememberNavController()
    WelcomeScreen(navController = navController)
}